

sql = """
        SELECT
        '1001'                                                     AS ACCT,
        B.COST_CENTER                                                      AS COST_CENTER,
        B.UNIT_CODE AS UNIT_CODE,
        '2020'                                 AS DATE,
        'CCL'  AS IND,
        '成材率'             AS IND_NAME,
        '%'                    AS IND_UNIT,
        ROUND(CASE WHEN SUM(COALESCE(VAL_M,0))=0 THEN 0 ELSE
        CAST(SUM(COALESCE(VAL_Z,0)) AS DOUBLE)/SUM(COALESCE(VAL_M,0))*100 END,3) AS INDEX_VALUE,
        '成材率'              AS REMARK,
        'BGRAGGCB' AS REC_REVISOR,
        TO_CHAR(CURRENT TIMESTAMP,'YYYYMMDDHH24MISS') AS REC_REVISOR_TIME
    FROM
        M1_JH.SA_JHBG_DSDMI1 A LEFT JOIN BGTAMAS1.T_ADS_WH_SICB_DP0102 B
    ON LEFT(A.ITEM_ID,4)=B.COST_CENTER
    WHERE
        A.ACCOUNT = '1001'
    AND A.ITEM_ID LIKE '%MI%'
    AND (A.RR='' OR  A.RR IS NULL)
    AND A.DATE_T BETWEEN '2020'||'0101' AND '2020'||'1231'
    GROUP BY B.COST_CENTER,B.UNIT_CODE
"""